﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project_Nested.Optimize
{
    public enum InstructionSet
    {
        BRK = 0x00,
        ORA_DpXInd = 0x01,
        CMP = 0x02,
        ORA_Sr = 0x03,
        TSB_Dp = 0x04,
        ORA_Dp = 0x05,
        ASL_Dp = 0x06,
        ORA_DpIndLong = 0x07,
        PHP = 0x08,
        ORA_Const = 0x09,
        ASL = 0x0a,
        PHD = 0x0b,
        TSB_Abs = 0x0c,
        ORA_Abs = 0x0d,
        ASL_Abs = 0x0e,
        ORA_Long = 0x0f,
        BPL_Br8 = 0x10,
        ORA_DpIndY = 0x11,
        ORA_DpInd = 0x12,
        ORA_SrIndY = 0x13,
        TRB_Dp = 0x14,
        ORA_DpX = 0x15,
        ASL_DpX = 0x16,
        ORA_DpIndLongY = 0x17,
        CLC = 0x18,
        ORA_AbsY = 0x19,
        INC = 0x1a,
        TCS = 0x1b,
        TRB_Abs = 0x1c,
        ORA_AbsX = 0x1d,
        ASL_AbsX = 0x1e,
        ORA_LongX = 0x1f,
        JSR_Jmp16 = 0x20,
        AND_DpXInd = 0x21,
        JSR_Jmp24 = 0x22,
        AND_Sr = 0x23,
        BIT_Dp = 0x24,
        AND_Dp = 0x25,
        ROL_Dp = 0x26,
        AND_DpIndLong = 0x27,
        PLP = 0x28,
        AND_Const = 0x29,
        ROL = 0x2a,
        PLD = 0x2b,
        BIT_Abs = 0x2c,
        AND_Abs = 0x2d,
        ROL_Abs = 0x2e,
        AND_Long = 0x2f,
        BMI_Br8 = 0x30,
        AND_DpIndY = 0x31,
        AND_DpInd = 0x32,
        AND_SrIndY = 0x33,
        BIT_DpX = 0x34,
        AND_DpX = 0x35,
        ROL_DpX = 0x36,
        AND_DpIndLongY = 0x37,
        SEC = 0x38,
        AND_AbsY = 0x39,
        DEC = 0x3a,
        TSC = 0x3b,
        BIT_AbsX = 0x3c,
        AND_AbsX = 0x3d,
        ROL_AbsX = 0x3e,
        AND_LongX = 0x3f,
        RTI = 0x40,
        EOR_DpXInd = 0x41,
        WDM_Const = 0x42,
        EOR_Sr = 0x43,
        MVP_Move = 0x44,
        EOR_Dp = 0x45,
        LSR_Dp = 0x46,
        EOR_DpIndLong = 0x47,
        PHA = 0x48,
        EOR_Const = 0x49,
        LSR = 0x4a,
        PHK = 0x4b,
        JMP_Jmp16 = 0x4c,
        EOR_Abs = 0x4d,
        LSR_Abs = 0x4e,
        EOR_Long = 0x4f,
        BVC_Br8 = 0x50,
        EOR_DpIndY = 0x51,
        EOR_DpInd = 0x52,
        EOR_SrIndY = 0x53,
        MVN_Move = 0x54,
        EOR_DpX = 0x55,
        LSR_DpX = 0x56,
        EOR_DpIndLongY = 0x57,
        CLI = 0x58,
        EOR_AbsY = 0x59,
        PHY = 0x5a,
        TCD = 0x5b,
        JMP_Jmp24 = 0x5c,
        EOR_AbsX = 0x5d,
        LSR_AbsX = 0x5e,
        EOR_LongX = 0x5f,
        RTS = 0x60,
        ADC_DpXInd = 0x61,
        PER_Br16 = 0x62,
        ADC_Sr = 0x63,
        STZ_Dp = 0x64,
        ADC_Dp = 0x65,
        ROR_Dp = 0x66,
        ADC_DpIndLong = 0x67,
        PLA = 0x68,
        ADC_Const = 0x69,
        ROR = 0x6a,
        RTL = 0x6b,
        JMP_JmpInd = 0x6c,
        ADC_Abs = 0x6d,
        ROR_Abs = 0x6e,
        ADC_Long = 0x6f,
        BVS_Br8 = 0x70,
        ADC_DpIndY = 0x71,
        ADC_DpInd = 0x72,
        ADC_SrIndY = 0x73,
        STZ_DpX = 0x74,
        ADC_DpX = 0x75,
        ROR_DpX = 0x76,
        ADC_DpIndLongY = 0x77,
        SEI = 0x78,
        ADC_AbsY = 0x79,
        PLY = 0x7a,
        TDC = 0x7b,
        JMP_JmpIndX = 0x7c,
        ADC_AbsX = 0x7d,
        ROR_AbsX = 0x7e,
        ADC_LongX = 0x7f,
        BRA_Br8 = 0x80,
        STA_DpXInd = 0x81,
        BRL_Br16 = 0x82,
        STA_Sr = 0x83,
        STY_Dp = 0x84,
        STA_Dp = 0x85,
        STX_Dp = 0x86,
        STA_DpIndLong = 0x87,
        DEY = 0x88,
        BIT_Const = 0x89,
        TXA = 0x8a,
        PHB = 0x8b,
        STY_Abs = 0x8c,
        STA_Abs = 0x8d,
        STX_Abs = 0x8e,
        STA_Long = 0x8f,
        BCC_Br8 = 0x90,
        STA_DpIndY = 0x91,
        STA_DpInd = 0x92,
        STA_SrIndY = 0x93,
        STY_DpX = 0x94,
        STA_DpX = 0x95,
        STX_DpY = 0x96,
        STA_DpIndLongY = 0x97,
        TYA = 0x98,
        STA_AbsY = 0x99,
        TXS = 0x9a,
        TXY = 0x9b,
        STZ_Abs = 0x9c,
        STA_AbsX = 0x9d,
        STZ_AbsX = 0x9e,
        STA_LongX = 0x9f,
        LDY_Const = 0xa0,
        LDA_DpXInd = 0xa1,
        LDX_Const = 0xa2,
        LDA_Sr = 0xa3,
        LDY_Dp = 0xa4,
        LDA_Dp = 0xa5,
        LDX_Dp = 0xa6,
        LDA_DpIndLong = 0xa7,
        TAY = 0xa8,
        LDA_Const = 0xa9,
        TAX = 0xaa,
        PLB = 0xab,
        LDY_Abs = 0xac,
        LDA_Abs = 0xad,
        LDX_Abs = 0xae,
        LDA_Long = 0xaf,
        BCS_Br8 = 0xb0,
        LDA_DpIndY = 0xb1,
        LDA_DpInd = 0xb2,
        LDA_SrIndY = 0xb3,
        LDY_DpX = 0xb4,
        LDA_DpX = 0xb5,
        LDX_DpY = 0xb6,
        LDA_DpIndLongY = 0xb7,
        CLV = 0xb8,
        LDA_AbsY = 0xb9,
        TSX = 0xba,
        TYX = 0xbb,
        LDY_AbsX = 0xbc,
        LDA_AbsX = 0xbd,
        LDX_AbsY = 0xbe,
        LDA_LongX = 0xbf,
        CPY_Const = 0xc0,
        CMP_DpXInd = 0xc1,
        REP_Const = 0xc2,
        CMP_Sr = 0xc3,
        CPY_Dp = 0xc4,
        CMP_Dp = 0xc5,
        DEC_Dp = 0xc6,
        CMP_DpIndLong = 0xc7,
        INY = 0xc8,
        CMP_Const = 0xc9,
        DEX = 0xca,
        WAI = 0xcb,
        CPY_Abs = 0xcc,
        CMP_Abs = 0xcd,
        DEC_Abs = 0xce,
        CMP_Long = 0xcf,
        BNE_Br8 = 0xd0,
        CMP_DpIndY = 0xd1,
        CMP_DpInd = 0xd2,
        CMP_SrIndY = 0xd3,
        PEI_Dp = 0xd4,
        CMP_DpX = 0xd5,
        DEC_DpX = 0xd6,
        CMP_DpIndLongY = 0xd7,
        CLD = 0xd8,
        CMP_AbsY = 0xd9,
        PHX = 0xda,
        STP = 0xdb,
        JMP_JmpIndLong = 0xdc,
        CMP_AbsX = 0xdd,
        DEC_AbsX = 0xde,
        CMP_LongX = 0xdf,
        CPX_Const = 0xe0,
        SBC_DpXInd = 0xe1,
        SEP_Const = 0xe2,
        SBC_Sr = 0xe3,
        CPX_Dp = 0xe4,
        SBC_Dp = 0xe5,
        INC_Dp = 0xe6,
        SBC_DpIndLong = 0xe7,
        INX = 0xe8,
        SBC_Const = 0xe9,
        NOP = 0xea,
        XBA = 0xeb,
        CPX_Abs = 0xec,
        SBC_Abs = 0xed,
        INC_Abs = 0xee,
        SBC_Long = 0xef,
        BEQ_Br8 = 0xf0,
        SBC_DpIndY = 0xf1,
        SBC_DpInd = 0xf2,
        SBC_SrIndY = 0xf3,
        PEA_Abs = 0xf4,
        SBC_DpX = 0xf5,
        INC_DpX = 0xf6,
        SBC_DpIndLongY = 0xf7,
        SED = 0xf8,
        SBC_AbsY = 0xf9,
        PLX = 0xfa,
        XCE = 0xfb,
        JSR_JmpIndX = 0xfc,
        SBC_AbsX = 0xfd,
        INC_AbsX = 0xfe,
        SBC_LongX = 0xff,

        // MX flags
        m = 0x200,
        x = 0x100,
        mx = 0x300,
        mod = 0x400,        // Modified instructions
        il = 0x800,

        // Modified internal jump and branches
        JMP_Label = JMP_Jmp16 + mod,
        BCC_Label = BCC_Br8 + mod,
        BCS_Label = BCS_Br8 + mod,
        BEQ_Label = BEQ_Br8 + mod,
        BNE_Label = BNE_Br8 + mod,
        BVC_Label = BVC_Br8 + mod,
        BVS_Label = BVS_Br8 + mod,
        BPL_Label = BPL_Br8 + mod,
        BMI_Label = BMI_Br8 + mod,
        BRA_Label = BRA_Br8 + mod,

        // Modified push/pull for P
        PHP_Usage = PHP + mod,
        PLP_Change = PLP + mod,

        // Intermediate language starts here    -------------------------------
        Label = 0x800,
        ReturnMarker,

        // Jsr Nes/Emulator
        JSR_Nes, JMP_Nes, JSR_Nes_Static, JMP_Nes_Static,
        JMP_Emu, JSR_Emu,
    }
}
